package com.example.demo.utils;

import com.example.demo.pojo.ResultMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class MessageUtils {
    public static String getMessage( boolean issysttem,String fromname,Object message){
        try {
            ResultMessage resultMessage=new ResultMessage();
            resultMessage.setIssystem(issysttem);
            resultMessage.setMessage(message);
            if(fromname!=null){
                resultMessage.setFromname(fromname);
            }
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(resultMessage);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return null;
    }
}
